package 盛水最多的容器;

import java.util.Scanner;

public class Main {
    static int N = 100010;
    static int[] h = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int i = 1; i <= n; i++) {
            h[i] = in.nextInt();
        }
        int res = 0;
        for (int i = 1, j = n; i < j; ) {
            res = Math.max(res, Math.min(h[i], h[j]) * (j - i));
            if (h[i] > h[j]) {
                j--;
            } else {
                i++;
            }
        }
        System.out.println(res);
    }
}
